home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / comm2 / mfstlntd.lha / telnetd2_0.lha / telnetd-2.0 / source / fakesr / test / testfakesr.c < prev   
C/C++ Source or Header  |  1995-01-15  |  1KB  |  80 lines

  1. #include <exec/types.h>
  2. #include <exec/ports.h>
  3. #include <exec/io.h>
  4. #include <fakesr.h>
  5. #include <proto/exec.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. struct IOStdReq *FsrCtl=NULL;
  10. struct MsgPort *CtlPort=NULL;
  11. struct FSRUnit *Unit=NULL;
  12. int UnitAdded=FALSE;
  13. int OpenCnt=0;
  14. int CloseUnitFlag=FALSE;
  15. int CloseUnitSignal=-1;
  16. struct Task *TestTask;
  17.  
  18. void Quit(int retcode)
  19. {
  20.     if (FsrCtl) {
  21.         if (FsrCtl->io_Device) CloseDevice(FsrCtl);
  22.         DeleteStdIO(FsrCtl);
  23.     }
  24.     if (CtlPort) DeletePort(CtlPort);
  25.     exit(retcode);
  26. }
  27.  
  28. ULONG OpenTest(void *IORequest)
  29. {
  30.     OpenCnt++;
  31.     CloseUnitFlag=TRUE;
  32.     Signal(TestTask,1<<CloseUnitSignal);
  33. }
  34.  
  35. ULONG CloseTest(void *IORequest)
  36. {
  37.     
  38. }
  39.  
  40. ULONG Test_BeginIO(void *IORequest)
  41. {
  42.     
  43. }
  44.  
  45. ULONG Test_AbortIO(void *IORequest)
  46. {
  47.     return 0; /* we don't support this */
  48. }
  49.  
  50. void main(void)
  51. {
  52.     
  53.     CtlPort=CreatePort(NULL,0);
  54.     if (!CtlPort) Quit(21);
  55.     FsrCtl=CreateStdIO(CtlPort);
  56.     if (!FsrCtl) Quit(22);
  57.     
  58.     if (OpenDevice("fakesr.device",FSR_CTLUNIT,FsrCtl,0)) {
  59.         FsrCtl->io_Device=NULL;
  60.         Quit(23);
  61.     }
  62.     Unit=calloc(sizeof(struct FSRUnit),1);
  63.     if (!Unit) Quit(24);
  64.     Unit->fsru_Num=FSR_UNITNONE;
  65.     Unit->fsru_Open=OpenTest;
  66.     Unit->fsru_Close=CloseTest;
  67.     Unit->fsru_BeginIO=Test_BeginIO;
  68.     Unit->fsru_AbortIO=Test_AbortIO;
  69.     
  70.     FsrCtl->io_Command=FSRCMD_ADDUNIT;
  71.     FsrCtl->io_Data=(APTR)Unit;
  72.     DoIO(FsrCtl);
  73.     UnitAdded=TRUE;
  74.     FsrCtl->io_Command=FSRCMD_REMUNIT;
  75.     FsrCtl->io_Data=(APTR)Unit;
  76.     DoIO(FsrCtl);
  77.     UnitAdded=FALSE;
  78.     CloseDevice(FsrCtl);
  79. }
  80.